import {Injectable} from '@angular/core';
import {Http} from '@angular/http';
import 'rxjs/add/operator/map';

@Injectable()
export class SmarketHttpService {

  constructor(private http: Http) {
  }

  post(cmd: string, body: object, url: string = '/uat-contentsb/') {
    body = $.extend({
      tenantId: 950,
      nodeId: 950,
      moduleId: 0,
      instanceId: 0
    }, body);
    return this.http.post(url + 'index.php', {
      command: {
        size: 0,
        orn: '02-0001-00000001',
        dst: '01-0401-00000001',
        type: 2,
        cmd: cmd,
        sess: '000_test_use_only_create_by_jack',
        seq: 0,
        ver: 1000,
        body: body
      }
    }).map(res => res.json().body);
  }
}
